package com.spider.web.url;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import org.apache.commons.io.FileUtils;

public class XingMingBean {
	public static String[] firstMingList = new String[] {"z", "a", "b", "c", "d", "e",
			"f", "g", "h", "i", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "u", "v",
			"w", "x", "y", "o" };

	

	public static Object[] getXings() {

		String fileDir = "c://baijiaxing.txt";
		File file = new File(fileDir);
		try {
			List<String> list = FileUtils.readLines(file);
			List<String>  listTemp =new ArrayList();
			listTemp.addAll(list);
		    List<String> rsList=new ArrayList();
		    System.out.println("-------------------------------------");
			for (String line : list) {
				
				int count=0;
				for(String t:rsList){
					if(line.equals(t)){
						count=count+1;
					}
				}
				if(count==0){
					rsList.add(line);
					
					 System.out.println(line );
					
				}else{
					//System.out.println(line);
				}
				
			 
			}
			 System.out.println("-------------------------------------");
		 return rsList.toArray();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}
	public static String[] getXingMingArray(){
		List<String> xingMingArray=new ArrayList<String>();
		int count=1;
		int countXing=0;
		  for(Object xing:XingMingBean.getXings()){
			  if(countXing<=40){
				  for(String ming:XingMingBean.firstMingList){
					  try{ 
						 // if(count<=15){
						  xingMingArray.add(xing+ming);
						  //System.out.println(count);
						  //System.out.println(xing+ming);		 
						  //}
						  count++;
					  }catch(Exception e){
						  e.printStackTrace();
					  }
					  
				  }
			  }else{
				  xingMingArray.add(xing.toString());
			  }
			  countXing++;
			   
		  }
		  
		  String[] stringArray=new String[]{};
		return   (String[]) xingMingArray.toArray(stringArray);
	}
	public static String getInfo(String tmpFile) throws IOException {
		StringBuffer sbFile;
		FileReader in = new FileReader(tmpFile);
		char[] buffer = new char[4096];
		int len;
		sbFile = new StringBuffer();
		while ((len = in.read(buffer)) != -1) {
			String s = new String(buffer, 0, len);
			sbFile.append(s);
		}
		return sbFile.toString();
	}
	public static void main(String[] args) {
		/* String[] arrays=getXingMingArray();
		System.out.println(" arrays.length="+arrays.length);
		for(String m:arrays){
			//System.out.println(" "+m);
		} */
		/*String fileDir = "c://baijiaxing.txt";
		File file = new File(fileDir);
		try {
			List list = FileUtils.readLines(file);
			for (Object line : list) {
				System.out.println(line);
			}
			System.out.println("list.size="+list.size());
			System.out.println("getXings().length="+getXings().length);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		 try {
			//String fileContent=getInfo("D:/error3/2.txt");
			//System.out.println( fileContent );
			//System.out.println(new String(fileContent.getBytes(),"GB2312"));
			List<String> list= getLines("D:/error3/2.txt" ) ;
			for(String line:list){
				if(line!=null){
					String url=line.substring( line.indexOf("C:")+2);
					System.out.println( url );
				}
				
			}
		 
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
	public static List<String> getLines( String fileName )  

	{  

	    List<String> lines = new ArrayList<String>();  

	    try  

	    {  

	        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "GB2312"));  

	        String line = null;  

	        while( ( line = br.readLine() ) != null )  
	        	lines.add(line);  
	        
	        br.close();  

	    }  

	    catch( FileNotFoundException e )  

	    {  

	    }  

	    catch( IOException e )  

	    {  

	    }  

	    return lines;  

	}  

}
